import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:klfz_flutter/book/widgets/reader_page_agent.dart';
import 'package:klfz_flutter/config/ReaderConfig.dart';
import 'package:klfz_flutter/model/chapter_result.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class BookReadLogic extends GetxController {

  int pages = 0;

  //当前章
  int current_chapter = 1;
  //当前页
  int current_page = 1;

  //获取当前章总页数
  getPages(Chapter chapter, double fontSize) {
    var pageOffsets = ReaderPageAgent.getPageOffsets(chapter.content ?? "", ReaderConfig.getReaderSceneHeight(), ReaderConfig.getReaderSceneWidth(), fontSize);
    chapter.pageOffsets = pageOffsets;
    return chapter;
  }

  void updateCurrentPage(int page, int chapter) {
    current_page = page;
    current_chapter = chapter;
    update();
  }
}
